//
//  SchoolListVC.swift
//  LeGou
//
//  Created by 刘亿前 on 2022/10/14.
//

import UIKit

class SchoolListVC: ZMViewController {
    
    lazy var listTable: UITableView = {
        let table = UITableView()
        table.delegate = self
        table.dataSource = self
        table.separatorColor = UIColor.zm.color(hexString: "#000000", 0.06)
        table.separatorInset = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16)
        table.rowHeight = 100
        table.estimatedRowHeight = UITableView.automaticDimension
        table.register(UINib(nibName: "SchoolListCell", bundle: nil), forCellReuseIdentifier: "SchoolListCell")
        table.showsVerticalScrollIndicator = false
        table.backgroundColor = .clear
        table.tableFooterView = UIView()
        view.addSubview(table)
        table.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        return table
    }()
    
    var current = 1
    var dataArr = [SchoolInfoModel]()
    var cid = 0

    override func viewDidLoad() {
        super.viewDidLoad()
        glt_scrollView = listTable
        addRefresh(scrollView: listTable) { [unowned self] refresh in
            self.current = refresh ? 1 : self.current + 1
            self.requestList()
        }
        listTable.mj_header?.beginRefreshing()
    }

}

extension SchoolListVC: UITableViewDelegate, UITableViewDataSource {
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return dataArr.count
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return UITableView.automaticDimension
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "SchoolListCell", for: indexPath) as! SchoolListCell
        
        return cell
    }
}

// MARK: - Request Action
extension SchoolListVC {
    func requestList() {
        
    }
}
